﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VeryExtremeArt.Controller;

namespace VeryExtremeArt
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            loginSubmit.Click += loginSubmit_Click;
            if (Session["message"] != null && Session["message"].ToString() != "")
            {
                Response.Write("<script>window.alert('" + Session["message"].ToString() + "')</script>");
                Session.Remove("message");
            }
        }

        void loginSubmit_Click(object sender, EventArgs e)
        {
            MemberController membCtrl = new MemberController();
            Member b = membCtrl.Login(username.Text, password.Text);

            if (b != null)
            {
                Session["username"] = b.UserName;
                Session["password"] = b.Password;
                Response.Redirect("~/");
            }
        }
    }
}